# Linux Development 2010

Linux Development 2010
Introduction

I'd like to program in Linux, where should I start?

It depends.

This presentation is the long answer

Introduce my self

Raul Suarez

Using Linux for about 6 years

Programming for 28 (Professionally just 24)

twitter: @rarsamx

email: rarsa@yahoo.com

blog: http://rarsa.blogspot.com

blog: http://www.kwlug.org/blog/48

Housekeeping

I welcome questions and comments during the presentation, but there are two kind of questions that I will defer for later.

- Questions or comments about things I'll talk later.
- Comments or questions about particular technologies I didn't include

I will provide the full mind map with links and comments on my KWLUG blog.

Agenda
Census

Who is new to development?

Who is new to developing under Linux?

Programming Primer
What is programming

Providing instructions to the computer to perform a particular task.

Development Cycle
Planning

Deciding/Finding out what to program

Coding, testing and documenting

Creating the actual end result of the development

Deployment

Installing it where it will be executed

Maintenance

Adding/Removing/Modifying functionality

Ensuring compatibility with new libraries

Ensuring currency with new environments

Programming paradigms
Procedural

Provide step by step instructions on how to accomplish a task

Declarative

Say what we want to get, not how to get it. SQL, XPath, etc.

Language types
Scripting languages

Interpreted at run time

Faster turn around development

High portability

Shell Scripting

Automates the execution of commands that would normally be interpreted by the command line

bash - Bourn Again shell

the most common shell (Command line)

Tutorials

There are many tutorials. Google "Bash Tutorial".

My favourite: Steve-parker.org/sh

Reference

Bash reference accordion

C-shell csh

Scripting shell with C-like syntax

Korn shell ksh

Superset of Bash

Perl

Originally developed for text manipulation

Practical, not beautiful

Lots of regular expressions

Lots of 3rd party modules

OO although almost no-one uses OO with Perl

Has the concept of "current" variable

Tcl

Truly general purpose language

Easy to create GUIs

PHP

Hypertext preprocesor

Especially suited for Web development

In the same category of JSP and ASP

Anything that's not code is output

Python

General purpose OO

Easy to learn: Elegance and clarity are

Easy to read

Relies on C library functions

Ruby

A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.

Mostly used for Ruby on Rails

Everything is an object

Many others
Intermediate language

Compiled into an intermediate language which is interpreted at run time

Good portability

An interpreter (virtual machine) must exist to run them

Java: Java, Jyton, Scala, etc

Java is a programming language and computing platform (Virtual machine)

JVM - Runtime

JDK - Development libraries

Mono: C#,VB.NET, etc

An open source, cross-platform, .NET development framework compatible with Microsoft.NET

...
Compiled languages

Compiled directly into machine language

Non portable: Must be recompiled for different OSs and hardware architectures.

Faster than the other two types in general.

C

Simple, powerful

Gives you all the rope you need to hang yourself

Ported to every platform

C++

Object Oriented language based on C

http://www.learncpp.com/

Pascal

Originally created to learn to program

Nice and simple syntax

Vala

General purpose

C meta language

C#-like syntax

Easy to link or wrap C libraries

Used in Gnome apps

...
Advice
Command line automation
Shell scripting
Learning to program
Scripting languages (Python, Ruby)
High Productivity
Intermediate languages
Scripting languages
High performance
Compiled
Low level
C
High Portability
C
Scripting
Intermediate languages
Programming Ecosystem overview

http://www.yolinux.com/TUTORIALS/LinuxTutorialSoftwareDevelopment.html

http://www.faqs.org/docs/ldev/

Development targets
Console

Also know as command line, terminal, character mode

no output

Some programs require no output, they just do whatever they do.

echo output

Other programs get information from the command line and send information to the command line.

nCurses

nCurses provides a framework to create nice looking UI (User Interface)s in text mode.

sudo aptitude install libncurses5-dev

dialog

Dialog allows displaying simple but useful text mode windows that show and get information

sudo aptitude install dialog

Examples under

/usr/share/doc/dialog/examples/

Graphical Desktop Environment

Graphical User Interface that allows the user to interact with programs graphically.

If you are targeting a particular Desktop environment, it is better if you develop under that environment to get all the dependencies, but test under another, to ensure you know what those dependencies are.

zenity, kdialog, gdialog, xdialog, GTKDialog

Simple dialogs, some of the utilities quite old

GTK dialog allows using interfaces designed with glade but it hasn't been updated in years

Gnome
KDE
XFCE
Enlightenment
Many others...
Web
Static

Presenting information to the reader with no interaction

Dynamic Server side

Interacts with the user but processing happens mostly on the server and requires full page refresh

Dynamic AJAX

Interacts with the user with the User interaction functionality on the client side. Information can be transferred asynchronously.

Mobile OS
Android

Google's mobile operating system

MeeGo

Fusion of Mobilin (Intel) and Maemo (Nokia)

WebOS

Palm's Linux based mobile OS

LiMO

Independent foundation

Embedded systems

Don't know much about embedded, but other people in the group do. Just ask around.

Basic toolset
Editor
GCC
GDB
Make
Libraries

Almost no one starts from Scratch in Linux. There are libraries for everything,

Applications are usually small and stable as they rely on 3rd party libraries

Toolkits (GUI libraries)

A toolkit is a set of programming libraries that work together to simplify development.

A toolkit provides a consistent architecture and API.

GTK

Gimp Tool Kit, used by Gnome and several other desktop environments

gtkmm are the bindings for C++

http://library.gnome.org/devel/references

QT

Highly portable Toolkit used by KDE and other environments such as Symbian and Maemo/MeeGo, Windows Mobile

EFL

Enlightenment semi-toolkit

XFC

XFCE wrapper to the GTK

FLTK

Fast and Light toolkit

wxWidgets

Cross platform: Uses Native Platform libraries

http://docs.wxwidgets.org/stable/

[TCL]
TK

Ugly

Tile

Less ugly

Gnocl

GTK

[Java]
AWT/Swing

Part of the Java Foundation Classes. Swing is built in top of AWT extending the functionality.

Pivot

RIA (Rich Internet Application) toolkit

Thinlet

Toolkit for J2SE

SWT

Developed by IBM as part of the Eclipse platform. Simpler than Swing but more limited

Many others...
Advice

If you care about integration into a particular desktop environment, then use that toolkit

If you don't then use the toolkit you feel most comfortable with

If you care about simplicity and portability more than looks TK/Tile

Development Frameworks

A set of libraries, interfaces, paradigms, utilities and architecture to simplify the development of complex systems.

Frameworks provide a consistent way of doing things liberating the developer from the details of the platform.

[for Ruby]
RubyOnRails
Other...
[for PHP]
Yii
Cake
Zoop
Others...
[for Perl]
Maypole
Catalyst
Jifty
Gantry
[for Python]
Django
Pylons
TurboGears
OpenLaszlo

Application framework for Rich internet applications.

Solo or Server deployment

Backend processing support

DHTML or Flash front end

Support for mobile applications

Netbeans plugin

Databases

Databases are special applications that help developers store, organize and access the data in a simple and consistent way.

RDBMS
MySQL
Postgress
SQLite
SAP DB
Non Relational

Don't use the relational model

No SQL
BerkleyDB
CouchDB
MongoDB
Cassandra
Valdemort
Interfaces
ODBC
JDBC
API libraries
Version Control Systems

Help you keep track of changes in your code.

Can help remember what you did to your code and when.

Helps communicating and coordinating with other developers working on the same project.

CVS

The grandfather of Linux version control systems.

Centralized model where all the changes go into a central repository.

It used to be the most popular but now most projects are migrating to other Version Control Systems.

Subversion

Subversion was created to overcome the limitations of CVS.

Centralized model where all the changes go into a central repository.

It is currently aging and some projects are migrating to distributed Version Control Systems

Git

Extremely fast distributed version control system.

Each developer has a personal repository where they can manage their own code and only integrate with other people's repository when they feel comfortable with their code.

Used by the Linux Kernel.

Many projects are migrating from CVS or Subversion to Git.

Many others...
Development Environments
Editors
Vim

Vim is a highly configurable text editor built to enable efficient text editing. It is an improved version of the vi editor distributed with most UNIX systems.

Can be configured to have syntax highlighting, code completion and integration with compilers and debugers.

I takes time to learn how to use it but once mastered it can be more productive than traditinal graphical IDEs.

Lighter than Emacs.

Emacs

Emacs is an extensible text editor.

Can be configured to have syntax highlighting, code completion and integration with compilers and debugers.

Mode files allow configuring it for particular development environments.

I takes time to learn how to use it but once mastered it can be more productive than traditinal graphical IDEs.

Some may say, more configurable than Vim.

NEdit
JEdit

Java based editor, ported to many platforms where Java is available

Plugins can be installed from within the editor.

Any Editor

Kate, Gedi, Geany and many other editors offer syntax highlighting and different degrees of integration with compilers and debuggers.

IDEs

IDE : Integrated Development Environment

IDEs are programs that provide facilities to the programmer,hiding details of project setup and compilation.

IDEs usually provide editors with syntax highlighting and code completion. Project management, Documentation generators, debuggers, compilers, etc. in a single package.

Anjuta (GTK)

Multilanguage IDE

C, C++, Java, Python

Requires wxWidgets

Git integration (Enable Git Plugin)

Integrated Glade for UI design (Although not well integrated with C++)

Must manually associate UI and code

KDevelop (KDE)

Unsupported in Lucid. Need to enable "Unsupported updates"

Can target KDE, Gnome and others

Used to be multilanguage on version 3.x for version 4 only C++ and PHP

Requires installing cmake separately (Ubuntu)

QT Creator

Created by Nokia, owners of QT

Highly polished

Only QT

Only C++

Code::Blocks (wxWidgets)

C++ IDE

Eclipse

Professional quality IDE

Extensible

Primarily Java but other language plugins available

Android development environment

Nice tutorials at http://www.vogella.de

BlackBerry development environment

NetBeans (Java)

Java based development environment

Oracle (formerly Sun) sponsored.

Plugins for several other languages and frameworks including PHP/Zend, RubyOnRails, C, C++.

MonoDevelop (.NET)

Development environment for the Mono framework.

Primarily C#

Plug-ins for other languages

For web development (ASP.NET) install xsp2

sudo aptitude install mono-xsp2

ASP.NET visual editor still under development

GTKSharp
Qyoto
wx.NET
Lazarus (FreePascal)

Just like the original Delphi

Desktop applications

Web Services toolkit for web services creation and consumption

Extensions for CGI development

Val(a)IDE

IDE for the Vala language

Android App Inventor

Program Android apps in a 100% graphical environment

Currently requires invitation.

Proprietary

Many vendors offer proprietary versions of their IDEs for Linux but with that many Free and Open Source environments, it is difficult to justify them.

Visual programming
Sikuli

Almost-typeless-environment to script GUI repetitive tasks.

Java based, Jython engine underneath

Not in repositories

Requires

- python-opencv
- libcvaux
- libcxxtools6

Context menus require capturing with another screen capture utility such as ksnapshot

Exporting to executable generates a file that can be executed by passing it as a parameter

Can create a shell script to execute without typing.

Open Blocks

Java library for creating blocks-based programming UIs.

Android - App Inventor

OpenBlocks based visual platform to develop Android applications

StarLogo TNG

http://education.mit.edu/drupal/starlogo-tng

Scratch

Scratch is a programming language that makes it easy to create your own interactive stories, animations, games, music, and art -- and share your creations on the web.

Packaging

In Linux it is common to distribute the the applications as packages that the target operating system knows how to install.

deb

deb packages are meant for Debian based systems, such as Deian, Ubuntu and Mint

rpm

rpm packages are meant for RedHat based systems such as RedHat, Fedora and Centos.

others ...

Different Linux distributions have their own package format. That's why vendors usually either target specific platforms or provide a generic tgz package.

Comparisons & Demos
Joining a FLOSS project

To join a Free and Open Source project you "usually" need to do the following:

- Use the application you want to contribute to.
- Learn the code (even if it is just a portion you are interested on)
- Contribute with small changes until the people in the corresponding development community know you

Eventually you will find your self contributing larger portions of code and seing your code and contributions used by many other people. It really feels good.

I said "usually" because different projects have different cultures and practices. Some are dictatorial with a single person deciding what is included into the code. Some others are democratic where people discuss what goes in. And some are quite open, with people contributing through different channels in an apparently cahotic way.